home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / atetris.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  9KB  |  288 lines

  1. /***************************************************************************
  2.  
  3. Atari Tetris Memory Map (preliminary)
  4.  
  5. driver by Zsolt Vasvari
  6.  
  7. 0000-0fff   RAM
  8. 1000-1fff   Video RAM
  9. 2000-20ff   Palette RAM
  10. 2400-25ff   EEPROM
  11. 4000-7fff   Paged ROM (Slapstic controlled)
  12. 8000-ffff   ROM
  13.  
  14. I/O
  15.  
  16. Read
  17.  
  18. 2800-280f Pokey #1
  19. 2800-281f Pokey #2
  20.  
  21. Write
  22.  
  23. 2800-280f Pokey #1
  24. 2810-281f Pokey #2
  25. 3000      Watchdog
  26. 3400      EEPROM enable
  27. 3800      ???
  28. 3c00      ???
  29.  
  30. ***************************************************************************/
  31.  
  32. #include "driver.h"
  33. #include "vidhrdw/generic.h"
  34.  
  35.  
  36. void atetris_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  37. READ_HANDLER( atetris_slapstic_r );
  38.  
  39.  
  40.  
  41. static unsigned char *nvram;
  42. static size_t nvram_size;
  43.  
  44. static void nvram_handler(void *file,int read_or_write)
  45. {
  46.     if (read_or_write)
  47.         osd_fwrite(file,nvram,nvram_size);
  48.     else
  49.     {
  50.         if (file)
  51.             osd_fread(file,nvram,nvram_size);
  52.         else
  53.             memset(nvram,0xff,nvram_size);
  54.     }
  55. }
  56.  
  57.  
  58.  
  59. static struct MemoryReadAddress readmem[] =
  60. {
  61.     { 0x0000, 0x20ff, MRA_RAM },
  62.     { 0x2400, 0x25ff, MRA_RAM },
  63.     { 0x2800, 0x280f, pokey1_r },
  64.     { 0x2810, 0x281f, pokey2_r },
  65.     { 0x4000, 0x7fff, atetris_slapstic_r },
  66.     { 0x8000, 0xffff, MRA_ROM },
  67.     { -1 }  /* end of table */
  68. };
  69.  
  70. static struct MemoryWriteAddress writemem[] =
  71. {
  72.     { 0x0000, 0x0fff, MWA_RAM },
  73.     { 0x1000, 0x1fff, videoram_w, &videoram, &videoram_size },
  74.     { 0x2000, 0x20ff, paletteram_RRRGGGBB_w, &paletteram },
  75.     { 0x2400, 0x25ff, MWA_RAM, &nvram, &nvram_size },
  76.     { 0x2800, 0x280f, pokey1_w },
  77.     { 0x2810, 0x281f, pokey2_w },
  78.     { 0x3000, 0x3000, watchdog_reset_w },
  79.     { 0x3400, 0x3400, MWA_NOP },  // EEPROM enable
  80.     { 0x3800, 0x3800, MWA_NOP },  // ???
  81.     { 0x3c00, 0x3c00, MWA_NOP },  // ???
  82.     { 0x4000, 0xffff, MWA_ROM },
  83.     { -1 }  /* end of table */
  84. };
  85.  
  86.  
  87. INPUT_PORTS_START( atetris )
  88.     // These ports are read via the Pokeys
  89.     PORT_START      /* IN0 */
  90.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN2 )
  91.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )
  92.     PORT_DIPNAME( 0x04, 0x00, "Freeze" )
  93.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  94.     PORT_DIPSETTING(    0x04, DEF_STR( On ) )
  95.     PORT_BITX(0x08, IP_ACTIVE_HIGH, IPT_SERVICE, "Freeze Step", KEYCODE_F1, IP_JOY_NONE )
  96.     PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_UNUSED )
  97.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_VBLANK )
  98.     PORT_SERVICE( 0x80, IP_ACTIVE_HIGH )
  99.  
  100.     PORT_START      /* IN1 */
  101.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER1)
  102.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_PLAYER1 | IPF_8WAY )
  103.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 | IPF_8WAY )
  104.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_PLAYER1 | IPF_8WAY )
  105.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2)
  106.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_PLAYER2 | IPF_8WAY )
  107.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 | IPF_8WAY )
  108.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_PLAYER2 | IPF_8WAY )
  109. INPUT_PORTS_END
  110.  
  111.  
  112. // Same as the regular one except they added a Flip Controls switch
  113. INPUT_PORTS_START( atetcktl )
  114.     // These ports are read via the Pokeys
  115.     PORT_START      /* IN0 */
  116.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN2 )
  117.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )
  118.     PORT_DIPNAME( 0x04, 0x00, "Freeze" )
  119.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  120.     PORT_DIPSETTING(    0x04, DEF_STR( On ) )
  121.     PORT_BITX(0x08, IP_ACTIVE_HIGH, IPT_SERVICE, "Freeze Step", KEYCODE_F1, IP_JOY_NONE )
  122.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED )
  123.     PORT_DIPNAME( 0x20, 0x00, "Flip Controls" )
  124.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  125.     PORT_DIPSETTING(    0x20, DEF_STR( On ) )
  126.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_VBLANK )
  127.     PORT_SERVICE( 0x80, IP_ACTIVE_HIGH )
  128.  
  129.     PORT_START      /* IN1 */
  130.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER1)
  131.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_PLAYER1 | IPF_8WAY )
  132.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 | IPF_8WAY )
  133.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_PLAYER1 | IPF_8WAY )
  134.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2)
  135.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_PLAYER2 | IPF_8WAY )
  136.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 | IPF_8WAY )
  137.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_PLAYER2 | IPF_8WAY )
  138. INPUT_PORTS_END
  139.  
  140.  
  141. static struct GfxLayout charlayout =
  142. {
  143.         8,8,    /* 8*8 chars */
  144.         2048,   /* 2048 characters */
  145.         4,      /* 4 bits per pixel */
  146.         { 0,1,2,3 },  // The 4 planes are packed together
  147.         { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4},
  148.         { 0*4*8, 1*4*8, 2*4*8, 3*4*8, 4*4*8, 5*4*8, 6*4*8, 7*4*8},
  149.         8*8*4     /* every char takes 32 consecutive bytes */
  150. };
  151.  
  152. static struct GfxDecodeInfo gfxdecodeinfo[] =
  153. {
  154.     { REGION_GFX1, 0x0000, &charlayout, 0, 16 },
  155.     { -1 } /* end of array */
  156. };
  157.  
  158.  
  159.  
  160. static struct POKEYinterface pokey_interface =
  161. {
  162.     2,      /* 2 chips */
  163.     1789790,    /* ? */
  164.     { 50, 50 },
  165.     /* The 8 pot handlers */
  166.     { 0, 0 },
  167.     { 0, 0 },
  168.     { 0, 0 },
  169.     { 0, 0 },
  170.     { 0, 0 },
  171.     { 0, 0 },
  172.     { 0, 0 },
  173.     { 0, 0 },
  174.     /* The allpot handler */
  175.     { input_port_0_r, input_port_1_r }
  176. };
  177.  
  178. static struct MachineDriver machine_driver_atetris =
  179. {
  180.     /* basic machine hardware */
  181.     {
  182.         {
  183.             CPU_M6502,
  184.             1750000,        /* 1.75 MHz??? */
  185.             readmem,writemem,0,0,
  186.             interrupt,4
  187.         }
  188.     },
  189.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,  /* frames per second, vblank duration */
  190.     1,      /* single CPU, no need for interleaving */
  191.     0,
  192.  
  193.     /* video hardware */
  194.     42*8, 32*8, { 0*8, 42*8-1, 0*8, 30*8-1 },
  195.     gfxdecodeinfo,
  196.     256, 256,
  197.     0,
  198.  
  199.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  200.     0,
  201.     generic_vh_start,
  202.     generic_vh_stop,
  203.     atetris_vh_screenrefresh,
  204.  
  205.     /* sound hardware */
  206.     0,0,0,0,
  207.     {
  208.         {
  209.             SOUND_POKEY,
  210.             &pokey_interface
  211.         }
  212.     },
  213.  
  214.     nvram_handler
  215. };
  216.  
  217.  
  218. /***************************************************************************
  219.  
  220.   Game driver(s)
  221.  
  222. ***************************************************************************/
  223.  
  224. ROM_START( atetris )
  225.     ROM_REGION( 0x14000, REGION_CPU1 )     /* 80k for code */
  226.     ROM_LOAD( "1100.45f",     0x0000, 0x10000, 0x2acbdb09 )
  227.  
  228.     ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  229.     ROM_LOAD( "1101.35a",     0x0000, 0x10000, 0x84a1939f )
  230. ROM_END
  231.  
  232. ROM_START( atetrisa )
  233.     ROM_REGION( 0x14000, REGION_CPU1 )     /* 80k for code */
  234.     ROM_LOAD( "d1",           0x0000, 0x10000, 0x2bcab107 )
  235.  
  236.     ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  237.     ROM_LOAD( "1101.35a",     0x0000, 0x10000, 0x84a1939f )
  238. ROM_END
  239.  
  240. ROM_START( atetrisb )
  241.     ROM_REGION( 0x14000, REGION_CPU1 )     /* 80k for code */
  242.     ROM_LOAD( "tetris.01",    0x0000, 0x10000, 0x944d15f6 )
  243.  
  244.     ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  245.     ROM_LOAD( "tetris.02",    0x0000, 0x10000, 0x5c4e7258 )
  246.  
  247.     /* there's an extra EEPROM, maybe used for protection crack, which */
  248.     /* however doesn't seem to be required to run the game in this driver. */
  249.     ROM_REGION( 0x0800, REGION_USER1 )
  250.     ROM_LOAD( "tetris.03",    0x0000, 0x0800, 0x26618c0b )
  251. ROM_END
  252.  
  253. ROM_START( atetcktl )
  254.     ROM_REGION( 0x14000, REGION_CPU1 )     /* 80k for code */
  255.     ROM_LOAD( "tetcktl1.rom", 0x0000, 0x10000, 0x9afd1f4a )
  256.  
  257.     ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  258.     ROM_LOAD( "1103.35a",     0x0000, 0x10000, 0xec2a7f93 )
  259. ROM_END
  260.  
  261. ROM_START( atetckt2 )
  262.     ROM_REGION( 0x14000, REGION_CPU1 )     /* 80k for code */
  263.     ROM_LOAD( "1102.45f",     0x0000, 0x10000, 0x1bd28902 )
  264.  
  265.     ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  266.     ROM_LOAD( "1103.35a",     0x0000, 0x10000, 0xec2a7f93 )
  267. ROM_END
  268.  
  269.  
  270.  
  271. static void init_atetris(void)
  272. {
  273.     unsigned char *RAM = memory_region(REGION_CPU1);
  274.  
  275.  
  276.     // Move the lower 16k to 0x10000
  277.     memcpy(&RAM[0x10000], &RAM[0x00000], 0x4000);
  278.     memset(&RAM[0x00000], 0, 0x4000);
  279. }
  280.  
  281.  
  282.  
  283. GAME( 1988, atetris,  0,       atetris, atetris,  atetris, ROT0,   "Atari Games", "Tetris (set 1)" )
  284. GAME( 1988, atetrisa, atetris, atetris, atetris,  atetris, ROT0,   "Atari Games", "Tetris (set 2)" )
  285. GAME( 1988, atetrisb, atetris, atetris, atetris,  atetris, ROT0,   "bootleg",     "Tetris (bootleg)" )
  286. GAME( 1989, atetcktl, atetris, atetris, atetcktl, atetris, ROT270, "Atari Games", "Tetris (Cocktail set 1)" )
  287. GAME( 1989, atetckt2, atetris, atetris, atetcktl, atetris, ROT270, "Atari Games", "Tetris (Cocktail set 2)" )
  288.